package com.own.business.system.menu.entity.vo;

import com.own.business.system.menu.entity.po.SystemUserRole;
import com.own.component.common.base.entity.vo.BaseBeanVo;
import com.own.constant.ConstantBeanSuffix;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import lombok.experimental.Accessors;

import java.io.Serializable;

/**
 * SystemUserRoleVo
 *
 * @author chenxueli
 * @date 2024-03-31 10:00:18
 */
@Schema(title = "系统用户角色" + ConstantBeanSuffix.VO)
@Getter
@Setter
@ToString
@Accessors(chain = true)
@AllArgsConstructor
@NoArgsConstructor
public class SystemUserRoleVo extends BaseBeanVo<SystemUserRole> implements Serializable {

    @Schema(title = "用户id")
    private Long userId;

    @Schema(title = "角色id")
    private Long roleId;

    /**
     * 构造方法
     *
     * @param entity 原对象
     */
    public SystemUserRoleVo(@NonNull SystemUserRole entity) {
        super(entity);
        this.userId = entity.getFkUserId();
        this.roleId = entity.getFkRoleId();
    }

    /**
     * 转po对象
     *
     * @param entity 原对象
     * @return po对象
     */
    @Override
    public SystemUserRole toPo(SystemUserRole entity) {
        if (entity == null) {
            entity = new SystemUserRole();
        }
        entity.setFkUserId(this.userId);
        entity.setFkRoleId(this.roleId);
        return super.toPo(entity);
    }

}
